GetApiUrl = function(url) {
	return "http://localhost:8088/" + url;
};
GetLocalUrl = function(url) {
	return "http://127.0.0.1:8000/View/" + url + ".html";
};

//Get请求
LocalGet = function(url, callback, async) {
	$.ajax({
		type: "get",
		url:url,
		data: {},
		dataType: "json",
		async: async == false ? false : true,
		xhrFields: {
			withCredentials: true
		},
		success: function(data) {
			if(data.state == '401') {
				dialogMsg(data.msg, 2);
				return false;
			}
			callback(data);
		},
		error: function(data) {
			layer.msg(data.msg);
		}

	});
}
//Get请求
HttpGet = function(url, callback, async) {
	$.ajax({
		type: "get",
		url:GetApiUrl(url),
		data: {},
		dataType: "json",
		async: async == false ? false : true,
		xhrFields: {
			withCredentials: true
		},
		success: function(data) {
			if(data.state == '401') {
				dialogMsg(data.msg, 2);
				return false;
			}
			callback(data);
		},
		error: function(data) {
			layer.msg(data.msg);
		}

	});
}
//Post请求
HttpPost = function(url, postdata, callback, async) {
	console.log(postdata);
	$.ajax({
		type: "post",
		contentType: "application/json;charset=utf-8",
		url:GetApiUrl(url),
		data: postdata,
		dataType: "json",
		async: async == false ? false : true,
		xhrFields: {
			withCredentials: true
		},
		success: function(data) {
			if(data.state == '401') {
				dialogMsg(data.msg, 2);
				return false;
			}
			callback(data);
		},
		error: function(data) {
			layer.msg(data.msg);
		}

	});
}

//ajax加载页面
$.fn.HttpLoad = function(url,data,callback) {
	var ele = $(this);
	$.ajax({
		type:"get",
		url:GetLocalUrl(url),
		async:false,
		dataType:"html",
		success:function(data){
			if(!IsNull(callback())){
				callback();
			}
			$(ele).html(data);
		}
	});
}

//判断对象是否为空 ture or false
IsNull = function(obj) {
	if(obj == null || obj == "" || obj == "undefined" || obj == Guid0)
		return true;
	else return false;
}

//获取Url参数值,传入参数名称
QueryUrlValue = function (name) {
    var result = location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
    if (result == null || result.length < 1) {
        return "";
    }
    return result[1];
}

